package com.lolo.sso.controller;

import com.lolo.sso.common.Constant;
import com.lolo.sso.vo.Oauth2ReqParam;
import com.lolo.sso.vo.Oauth2ResParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/unitrust")
public class AuthController {

    @PostMapping("/oauth2/client_credentials/access_token")
    public Oauth2ResParam Oauth2(@RequestBody Oauth2ReqParam oauth2ReqParam) {
        Oauth2ResParam resParam = new Oauth2ResParam();
        if (oauth2ReqParam.getApp_id().equals(Constant.db_app_id)
                && oauth2ReqParam.getApp_secret().equals(Constant.db_app_secret)) {
            resParam.setAccess_token(Constant.db_random_token);
            resParam.setToken_type("Beare");
            resParam.setRefresh_token("refresh_112233");
            resParam.setExpires_in("72000");
        }
        return resParam;
    }
}
